<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title><!--{if isset($content_center)}-->修改<!--{else}-->添加<!--{/if}-->活动页</title>
    <!--{include file='comm/comm_editor.tpl'}-->
    <!--{include file="comm/icheck.tpl"}-->
</head>

<body>
<div style="width:100%">

    <div class="items clearfix">

        <h2 style="" class="tal">
            正在操作：
            <!--{if isset($content_center)}-->修改<!--{else}-->添加<!--{/if}-->活动页
        </h2>

        <div class="items2">

            <form class="form-horizontal" id="content_form" role="form">

                <input type="hidden" name="contentID" id="contentID" value="0">

                <!--add by allen.qiang 2015-01-13 FUN-BK-0045-PC_WAP首页底下广告位按城市维护 start-->
                <div class="form-group">
                    <label class="col-sm-2 control-label" for="cityID">
                        <span class="red">*</span>
                        城市：
                    </label>
                    <div class="col-sm-10">
                        <select class="form-control input-sm" name="cityID" id="cityID" style="width: 100px;">
                            <option value="">请选择</option>
                            <!--{if isset($city_array)}-->
                            <!--{foreach from=$city_array item=city}-->
                            <option value="<!--{$city.id}-->"><!--{$city.name}--></option>
                            <!--{/foreach}-->
                            <!--{/if}-->
                        </select>
                        <input type="hidden" id="cityName" name="cityName" value="<!--{$content_center->cityName|default:''}-->"/>
                    </div>
                </div>
                <!--add by allen.qiang 2015-01-13 FUN-BK-0045-PC_WAP首页底下广告位按城市维护 end-->

                <div class="form-group">
                    <label class="col-sm-2 control-label" for="contentTitle">
                        <span class="red">*</span>
                        活动页标题：
                    </label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control w300" id="contentTitle" name="contentTitle" placeholder="请输入活动页标题" value="<!--{$content_center->contentTitle|default:''}-->">
                        <input type="hidden" name="contentID" id="contentID" value="<!--{$content_center->contentID|default:''}-->">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label"> 封面图片：</label>
                    <div class="col-sm-10">
                        <button type="button" class="btn btn-default" id="update_logo">点击封面图片</button>
                        <div id="logo_img_box" style="<!--{if !isset($content_center) || !isset($content_center->content_pic)  || empty($content_center->content_pic)}-->display: none;<!--{/if}-->margin-top: 5px;">
                            <img src="<!--{if isset($content_center)}--><!--{$content_center->content_pic_show|default:''}--><!--{/if}-->">
                        </div>
                        <input type="hidden" name="content_pic" id="content_pic" value="<!--{if isset($content_center)}--><!--{$content_center->content_pic|default:''}--><!--{/if}-->" />
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label" for="contentSort">
                        <span class="red">*</span>
                        排列序号：
                    </label>
                    <div class="col-sm-10">
                        <input id="contentSort" class="form-control w150" placeholder="请输入排列序号" value="<!--{$sortOrder}-->" name="contentSort" type="text">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label" for="searchKeys">
                        搜索关键字：
                    </label>
                    <div class="col-sm-10">
                        <input id="searchKeys" class="form-control w300" placeholder="请输入搜索关键字" value="<!--{$content_center->searchKeys|default:''}-->" name="searchKeys" type="text">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label" for="contentSummary">
                        活动页摘要：
                    </label>
                    <div class="col-sm-10">
                        <textarea class="form-control w500" id="contentSummary" name="contentSummary" placeholder="请输入活动页摘要"><!--{$content_center->contentSummary|default:''}--></textarea>
                    </div>
                </div>


                <div class="form-group">
                    <label class="col-sm-2 control-label" for="isethead-radio-1">
                        <span class="red">*</span>
                        是否要头部：
                    </label>
                    <div class="col-sm-10">

                            <div class="fl" style="margin-right: 10px;">
                                <input type="radio" class="square-radio" id="isethead-radio-1" name="isethead"  value="1" <!--{if $content_center->isethead == 1}-->checked<!--{/if}-->>
                                <label for="isethead-radio-1">是</label>
                            </div>
                            <div class="fl">
                                <input type="radio" class="square-radio" id="isethead-radio-0" name="isethead" value="0" <!--{if $content_center->isethead == 0}-->checked<!--{/if}-->>
                                <label for="isethead-radio-0">否</label>
                            </div>

                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label" for="isetstern-radio-1">
                        <span class="red">*</span>
                        是否要尾部：
                    </label>
                    <div class="col-sm-10">

                            <div class="fl" style="margin-right: 10px;">
                                <input type="radio" class="square-radio" id="isetstern-radio-1" name="isetstern"  value="1" <!--{if $content_center->isetstern == 1}-->checked<!--{/if}-->>
                                <label for="isetstern-radio-1">是</label>
                            </div>
                            <div class="fl">
                                <input type="radio" class="square-radio" id="isetstern-radio-0" name="isetstern" value="0" <!--{if $content_center->isetstern == 0}-->checked<!--{/if}-->>
                                <label for="isetstern-radio-0">否</label>
                            </div>
                    </div>
                </div>

                <div class="form-group" id="ifChecked_1">
                    <label class="col-sm-2 control-label" for="url_link">
                        <span class="red">*</span>
                        外部链接：
                    </label>
                    <div class="col-sm-10">

                        <input type="text" class="form-control w500" id="url_link" name="url_link" maxlength="200" value="<!--{$content_center->url_link|default:''}-->">
                        <span class="help-block">外部链接和描述内容必须填写一个</span>
                    </div>
                </div>


                <div style=" margin-top:8px;">
                    <!--{if isset($content_center)}-->
                    <textarea name="description" id="description" style="width:100%;height:400px;visibility:hidden;"><!--{$content_center->description}--></textarea>
                    <!--{else}-->
                    <textarea name="description" id="description" style="width:100%;height:400px;visibility:hidden;"></textarea>
                    <!--{/if}-->

                </div>
            </form>

        </div>
    </div>
    <div style="height:45px;"></div>

    <div class="bottom_fixbox">
        <div class="tac popup-footer">
            <input type="button" class="btn btn-success" onclick="content.check();" value="<!--{if isset($content_center)}-->修改<!--{else}-->添加<!--{/if}-->活动页" />&nbsp;&nbsp;&nbsp;
            <input type="button" class="btn btn-default" onclick="E.closeWindows();" value="关闭" />
        </div>
    </div>



</div>

<script type="text/javascript">

    //add by allen.qiang 2015-01-13 FUN-BK-0045-PC_WAP首页底下广告位按城市维护 ---start
    $(function() {
        var cityId="<!--{$content_center->cityID|default:''}-->";
        $("#cityID").val(cityId);
        $('#cityID').change(function() {
           $("#cityName").val($(this).find("option:selected").text());
        });
    });
    //add by allen.qiang 2015-01-13 FUN-BK-0045-PC_WAP首页底下广告位按城市维护 ---end

    $(window).ready(function() {

        $('.square-radio').iCheck({
            checkboxClass: 'icheckbox_square-blue',
            radioClass: 'iradio_square-blue',
            increaseArea: '20%' // optional
        });

        $('input[name=goods-search-type]').on('ifChecked', function() {
            if ($(this).val() == 1) {
                $('#ifChecked_1').show();
                $('#ifChecked_2').hide();
            } else {
                $('#ifChecked_2').show();
                $('#ifChecked_1').hide();
            }
        });

    });

    window.editor = KindEditor.create("#description");

    var content = {

        //切换标签
        changeType : function(type){
            if (type == 1) {
                $('#keyword').removeAttr('disabled');
                $('#postIDStr').attr('disabled','true');
                $('#postIDStr').val('');
            } else if(type == 2) {
                $('#keyword').attr('disabled','true');
                $('#postIDStr').removeAttr('disabled');
                $('#keyword').val('');
            }
        },

        //检查
        check : function(){

            editor.sync();

            this.dt = E.getFormValues('content_form');
            var error_msg = '';
            //add by allen.qiang 2015-01-13 FUN-BK-0045-PC_WAP首页底下广告位按城市维护 ---start
            if (this.dt.cityID == '') {
                error_msg += '请选择城市<br/>';
            }
            //add by allen.qiang 2015-01-13 FUN-BK-0045-PC_WAP首页底下广告位按城市维护 ---end
            if (this.dt.contentTitle == '') {
                error_msg += '请输入活动页标题<br/>';
            }

            if (!E.isInt(this.dt.contentSort) || this.dt.contentSort <= 0) {
                error_msg += '请输入正确的排列序号<br/>';
            }

            if (E.isEmpty(this.dt.url_link) && E.isEmpty(this.dt.description)){
                error_msg += "请填写外部链接或者描述内容<br />";
            }

            if (error_msg != '') {
                E.alert(error_msg);

            }else{
                //mod by allen.qiang 2015-01-13 FUN-BK-0045-PC_WAP首页底下广告位按城市维护 ---start
                var msg="您确认修改活动页吗？";
                if("<!--{$content_center->cityID|default:''}-->"==""){
                    msg="您确认添加活动页吗？";
                }
                E.confirm(msg, 'content.add');
                //mod by allen.qiang 2015-01-13 FUN-BK-0045-PC_WAP首页底下广告位按城市维护 ---start
            }



        },

        //添加活动页管理
        add : function(){
            E.ajax_post({
                url : "/invokingAjax-backend/content/center.ajax?operFlg=100&act=edit",
                data : {
                    content : this.dt
                },
                call : 'content.result'
            })
        },

        //回调
        result : function(o){
            if (o.code == 200) {
                E.alert(o.message, 2);
                E.opener('content.load');
                if (o.type == 1) {
                    self.location = '/quanliadmin/app/content/contentCenter.pscript?operFlg=2';
                } else {
                    setTimeout("E.closeWindows()", 2000);
                }
            } else {
                E.alert(o.message);
            }
        }
    };


    KindEditor.ready(function(K) {

        var kindEditor_upload = K.editor({
            allowFileManager : true,
            uploadJson: '/framework/kindeditor/php/upload_json.php?act=system'
        });

        $(document).on('click', '#update_logo', function() {

            kindEditor_upload.loadPlugin('image', function() {
                kindEditor_upload.plugin.imageDialog({
                    showRemote : false,
                    clickFn : function(url) {
                        $('#logo_img_box').html('<img src="' + url + '"> <a href="javascript: void(0);" id="del_log_img"></a>').show();
                        $('#content_pic').val(url);
                        kindEditor_upload.hideDialog();

                    }
                });
            });

        });

    });
</script>

</body>

</html>